package com.yztc.youbadbad.ui.other.fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.yztc.youbadbad.R;
import com.yztc.youbadbad.adapter.MyPagerAdapter;
import com.yztc.youbadbad.base.BaseFragment;
import com.yztc.youbadbad.ui.oversea.OverseaAllFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * KIO
 * 海外的tablayout
 * A simple {@link Fragment} subclass.
 */
public class OverseaFragment extends BaseFragment {

    @BindView(R.id.tablayout_sea_fg)
    TabLayout tablayoutSeaFg;
    @BindView(R.id.eventTabViewLine)
    View eventTabViewLine;
    @BindView(R.id.viewpager_sea_fg)
    ViewPager viewpagerSeaFg;
    @BindView(R.id.imageView_btntop_sea)
    ImageView imageViewBtntopSea;

    private Context mContext = getActivity();
    private String[] mTabArr_sea;//顶部导航的标题数组
    private List<Fragment> mTabList_sea = new ArrayList<>();
    private int[] mTabArr_seaid;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_oversea, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initDataAndView();
    }

    private void initDataAndView() {
//        导入tablayout的国家名字
        mTabArr_sea=getResources().getStringArray(R.array.oversea_tab);
        mTabArr_seaid = getResources().getIntArray(R.array.oversea_tabid);
        for (int i = 0; i < mTabArr_sea.length; i++) {
            Fragment  fragment = OverseaAllFragment.newInstance(mTabArr_seaid[i]);
            mTabList_sea.add(fragment);
        }
//        初始化视图
        MyPagerAdapter seaPagerAdapter=new MyPagerAdapter(getChildFragmentManager(),mTabList_sea,mTabArr_sea);
        viewpagerSeaFg.setAdapter(seaPagerAdapter);
        tablayoutSeaFg.setupWithViewPager(viewpagerSeaFg);
    }

    @OnClick(R.id.imageView_btntop_sea)
    public void onClick() {
    }
}
